//
//  NSDictionary+Change.m
//  QXBSystem
//
//  Created by tongbinLi on 16/6/30.
//  Copyright © 2016年 tongbinLi. All rights reserved.
//

#import "NSDictionary+Change.h"

@implementation NSDictionary (Change)

-(NSString *)changeToUrlSuffix{
    
    if (self.allKeys.count == 0) {
        return @"";
    }
    NSMutableString *suffix = [NSMutableString string];
    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        [suffix appendFormat:@"%@=%@&",key,obj];

    }];
//    [self bk_each:^(id  _Nonnull key, id  _Nonnull obj) {
//        
//        [suffix appendFormat:@"%@=%@&",key,obj];
//    }];
    return [suffix substringToIndex:suffix.length - 1];
}

- (BOOL)isModefiedCompareWithOriginDic:(NSDictionary *)originDic {
    NSArray *allKeys = self.allKeys;
    for (NSString *key in allKeys) {
        if ([originDic valueForKey:key]) {
            if (![[originDic valueForKey:key] isEqual:[self valueForKey:key]]) {
                return true;
            }
            
        }else {
            
            return true;
        }
    }
    return false;
}
@end
